package org.example.leetcode.core.controller;


import org.apache.ibatis.annotations.Delete;
import org.example.leetcode.common.pojo.GlobalResponse;
import org.example.leetcode.common.pojo.PageResult;
import org.example.leetcode.core.domain.TQuestionType;
import org.example.leetcode.core.dto.QuestionTypeQueryCond;
import org.example.leetcode.core.service.TQuestionTypeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhc
 * @since 2024-02-25
 */
@RestController
@RequestMapping("/t-question-type")
public class TQuestionTypeController {
    @Resource
    private TQuestionTypeService tQuestionTypeService;
    @GetMapping("/all")
    public GlobalResponse<List<TQuestionType>> getAllType(){
        return GlobalResponse.success(tQuestionTypeService.all());
    }
    @PostMapping("/page")
    public GlobalResponse<PageResult<TQuestionType>> getType(@RequestBody QuestionTypeQueryCond questionTypeQueryCond){
        return GlobalResponse.success(tQuestionTypeService.page(questionTypeQueryCond));
    }
    @PostMapping("/add")
    public GlobalResponse<Boolean> add(@RequestBody TQuestionType tQuestionType){
        tQuestionTypeService.add(tQuestionType);
        return GlobalResponse.success(Boolean.TRUE);
    }
    @Delete("/{code}")
    public GlobalResponse<Boolean> delete(@PathVariable("code")String code){
        tQuestionTypeService.delete(code);
        return GlobalResponse.success(true);
    }

}

